<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>GT pro钱包</title>
		<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
		<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
		<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
		<link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css">
		<link rel="stylesheet" href="bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
		<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
		<link rel="stylesheet" href="dist/css/skins/skin-blue.min.css">
		<link rel="stylesheet" href="css/style.css">
		<link rel="stylesheet" href="css/card.css">
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">

		<link rel="stylesheet" href="bower_components/bootstrap-daterangepicker/daterangepicker.css">
		<link rel="stylesheet" href="bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
		<style>
			.div-hidden {
				width: 200px;
				overflow: hidden;
				/*内容超出后隐藏*/
				text-overflow: ellipsis;
				/* 超出内容显示为省略号*/
				white-space: nowrap;
				/*文本不进行换行*/
			}
		</style>
	</head>

	<body class="hold-transition skin-blue sidebar-mini">
		<div class="wrapper">
			<div class="content-wrapper">
				<section class="content-header">
					<ol class="breadcrumb">
						<li>
							<a href="#"><i class="fa fa-dashboard"></i>系统安全</a>
						</li>
						<li class="active">错误日志</li>
					</ol>
				</section>
				<section class="content">
					<div class="box">
						<div class="box-header with-border">
							错误列表
						</div>
						<div class="box-body">
							<div class="buyu_search_group">
								<div class="row">
									<div class="col-xs-12 col-sm-6 col-lg-3">
										<div class="input-group margin">
											<div class="input-group-btn">
												<button type="button" class="btn btn-default" aria-expanded="false">状态 </button>
											</div>
											<select type="text" class="form-control" id="status">
												<option value="">全部</option>
												<option value="1">未处理</option>
												<option value="2">忽略</option>
												<option value="3">已处理</option>
											</select>
										</div>
									</div>

									<div class="col-xs-12 col-sm-6 col-lg-3">
										<div class="input-group margin">
											<div class="input-group-btn">
												<button type="button" class="btn btn-default" aria-expanded="false">时间</button>
											</div>
											<!-- /btn-group -->
											<input type="text" class="form-control" id="register_time">
											<div class="input-group-addon clearBtns" onclick="clearRangeTime(this)">x</div>
										</div>
									</div>

									<div class="col-xs-12 col-sm-6 col-lg-3">
										<button type="button" class="btn bg-primary margin" onclick="search()"><i class="fa fa-search" ></i>&nbsp;搜索</button>
										<button type="button" class="btn bg-primary margin" onclick="reset()"><i class="fa fa-trash" ></i>&nbsp;重置</button>
									</div>

								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-xs-12">
								<!-- /.box-header -->
								<div class="box-body">
									<table id="example" class="display nowrap table table-bordered table-striped" style="width:100%;">
										<thead>
											<tr>
												<th>ID</th>
												<th>类型</th>
												<th>异常详情</th>
												<th>状态</th>
												<th>出险时间</th>
												<th>修复时间</th>
												<th>修复管理员</th>
												<th>操作</th>
											</tr>
										</thead>
										<tbody></tbody>
									</table>
								</div>
							</div>
						</div>
					</div>
				</section>
			</div>
		</div>
		<div class="modal fade parents in" id="errorModal">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header"> 
						<button type="button" class="close" data-dismiss="modal" aria-label="Close">	                  				
							<span aria-hidden="true">×</span>								
						</button>
						<h4 class="modal-title">错误处理</h4> 
					</div>
					<div class="modal-body" style="margin-bottom:60px;">
						<form class="form-horizontal">
							<input type="hidden" name="id" value="">
							<label class="margin-bottom-none col-xs-12">错误处理情况
								<select class="form-control" name="status">
									<option value="1">未处理</option>
									<option value="2">忽略</option>
									<option value="3">已处理</option>
								</select>
							</label>
						</form>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-primary save" onclick="errorSave()">确定</button>
					</div>
				</div>
			</div>
		</div>
		<script src="bower_components/jquery/dist/jquery.min.js"></script>
		<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
		<script src="bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
		<script src="bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>

		<script src="bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
		<script src="bower_components/moment/min/moment.min.js"></script>
		<script src="bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>

		<script src="dist/js/adminlte.min.js"></script>
		<script src="js/argument.js"></script>
		<script src="js/fun.js"></script>
		<script src="js/nav.js"></script>
		<script src="js/pop.js"></script>
		<script src="js/getList.js"></script>
		<script type="text/javascript">
			$('#select_time').daterangepicker({
				timePicker: true,
				timePicker24Hour: true,
				autoUpdateInput: false,
				locale: {
					format: "YYYY-MM-DD HH:mm"
				}
			})
			var table = $('#example').DataTable({
				'ordering': false,
				'lengthChange': false,
				'searching': false,
				'info': true,
				"processing": true,
				"serverSide": true,
				'scrollX':true,
				"ajax": {
					"type": 'post',
					"url": url + "Back_ErrorLogList",
					'contentType': "application/x-www-form-urlencoded",
					"headers": {
						"auth-token": localStorage.getItem("wallet_token")
					},
					"data": function(d) {
						var data = {};
						data.data = JSON.stringify({
							page_num: d.start / 10 + 1,
							status: $("#status").val(),
							start_time: $("#start_time").val(),
							end_time: $("#end_time").val(),
						});
						return data;
					},
					"dataFilter": function(data) {
						var datajson = eval('(' + data + ')');
						if(datajson.status == 1000||datajson.status == 102) {
							ToLogin(datajson)
							return false;
						} else if(datajson.status != 1) {
							alert(datajson.error);
							return false;
						}
						var json = {};
						if(datajson.data == null) {
							json.recordsTotal = 0;
							json.recordsFiltered = 0;
							json.data = [];
							return JSON.stringify(json);
						} else {
							json.recordsTotal = datajson.data.total;
							json.recordsFiltered = datajson.data.total;
							json.data = datajson.data.data_list;
							return JSON.stringify(json);
						}
					}
				},
				"columns": [{
						data: 'id'
					},
					{
						data: 'status'
					},
					{
						data: null,
						render: function(data) {
							return '<div class="div-hidden" title="' + data.details + '">' + data.details + '</div>'
						}
					},
					{
						data: null,render:function(data){
							var statusList= {
								1:"未处理",
								2:"忽略",
								3:"已处理",
							}
							return statusList[data.status];
						}
					},
					{
						data: 'o_time'
					},
					{
						data: 'time'
					},

					{
						data: 'manager_id'
					},
					{
						data: null,
						render: function(data) {
							disabled = 'disabled';
							if(data.status == 1) {
								disabled = '';
							}
							return "<button type='button' " + disabled + " class='btn btn-primary button-margin ' onClick = 'error("+data.id+")'><i class='fa fa-warning'></i>&nbsp;操作</button>"
						}
					}
				]
			})
		</script>
		<script type="text/javascript">
			function error(id){
				$("#errorModal").modal('show');
				$("#errorModal [name=id]").val(id);
			}
			function errorSave(){
				if(!$("#errorModal [name=status]").val()){
					console.log($("#errorModal [name=status]").val())
					return false;
				}
				$.ajax({
					"type": 'post',
					"url": url + 'Back_ErrorLogUpdate',
					'contentType': "application/x-www-form-urlencoded",
					"headers": {
						"auth-token": localStorage.getItem("wallet_token")
					},
					data:{
						data:JSON.stringify({status:$("#errorModal [name= status]").val(),id:$("#errorModal [name=id]").val()})
					},
					success:function(res){
						if(res.status == 1000||res.status == 102){
							ToLogin(res)
							return false;
						}else if(res.status!=1){
							alert(res.error)
							return false;
						}
						$("#errorModal").modal('hide')
					}
				})
			}
		</script>
	</body>

</html>